********************************************************************************************************************************
*** Title: The Choice Between Intergovernmentalism and Nongovernmentalism: Projecting Domestic Preferences to Global Governance
***
***
*** Authors: Alexandru Grigorescu & Caglayan Baser
***
*** Journal: World Politics
********************************************************************************************************************************

*Created using STATA 14

********************************************************************************************************************************

*************Datasets*******************

*Dataset1: Cross-National Time-Series Data Archive.
   *Reference: Banks, Arthur S, and Kenneth A. Wilson. 2015. Cross-National Time-Series Data Archive. Databanks International. Jerusalem, Israel, http://www.databanksinternational.com 
	*Used for revexp5 (government spending), econ1 (GDP), pop1 (population), phone1 & trade 3 (interactions//interdependence), milexp1 (military expenditure) *Missing data were imputed (assuming linearity)

*Dataset2: National Material Capabilities (NMC) dataset (v4.0).  
   *Reference: Singer, J. David, Stuart Bremer, and John Stuckey. (1972). "Capability Distribution, Uncertainty, and Major Power War, 1820-1965." in Bruce Russett (ed) Peace, War, and Numbers, Beverly Hills: Sage, 19-48.
	*Used for cinc (CINC score//Degree to which world is dominated by world powers)

*Dataset3: MIDB_4.01: Data on MIDs from 1816-2010, at the participant level  (Correlates of War)
   *Reference: Ghosn, Faten, Glenn Palmer, and Stuart Bremer. 2004. "The MID3 Data Set, 1993–2001: Procedures, Coding Rules, and Description." Conflict Management and Peace Science 21:133-154. 
	*Used for mid (conflict)

*Dataset 4: State System Membership
	*Reference: Correlates of War Project.  2011.  “State System Membership List, v2011.” http://correlatesofwar.org.
	 *Used for newstates1 (proportion of new states in the past year), totstate (total number of states)

*Dataset 5: Foundation dates of International Organizations (51st ed.), Yearbook of IOs
	*Refence: Union of International Associations. 2015. Yearbook of International Organizations. Union of International Associations, Brussels, Belgium
	 *Used for IGOf1 (newIGOs: IGO emergence-DV), IGOs (existing IGOs), NGOs (existing NGOs), NGOf_int (new international NGOs)

*Dataset 6: COW International Governmental Organizations dataset (IGO State Unit v2.3)
	*Reference: Pevehouse, Jon, Timothy Nordstrom and Kevin Warnke. 2004. “The Correlates of War 2 International Governmental Organizations Data Version 2.0 Conflict.” Conflict Management and Peace Science 21, no. 2: 101-119.
	 *Used for IOchange5years (percentage of the change in the IO membership over 5 years), IOchange (percentage of the change in the IO membership), maxIO
	 
*Dataset 7: Polity IV
	*Reference: Marshall, Monty G. and Keith Jaggers. 2002. Polity IV Project: Political Regime Characteristics and Transitions, 1800-2002. Version p4v2002e [Computer File]. Center for International Development and Conflict Management, College Park, MD: University of Maryland. 
	 *Used for democ1 (democracy)

*Dataset 8: Alliance Treaty Obligations and Provisions Dataset (ATOP)
	*Reference: Leeds, Brett Ashley, Jeffrey M. Ritter, Sara McLaughlin Mitchell, and Andrew G. Long. 2002. Alliance Treaty Obligations and Provisions, 1815-1944. International Interactions 28: 237-260, http://atop.rice.edu/download/ATOPcdbk.pdf	 
	 *Used for organ1 (security organizations)


	 
	 
***********TABLE 1************	 
	 
***IGO emergence***Dependent Variable***
gen IGOf1 = (AIGO + BIGO + CIGO + DIGO + EIGO + FIGO)
lab var IGOf1 "number of newly founded organizations at a given year"
lab var AIGO "number of A-type IGOs founded in a given year"
lab var BIGO "number of B-type IGOs founded in a given year" 
lab var CIGO "number of C-type IGOs founded in a given year"
lab var DIGO "number of D-type IGOs founded in a given year"
lab var EIGO "number of E-type IGOs founded in a given year"
lab var FIGO "number of F-type IGOs founded in a given year"

***IGOs***
gen IGOf1 = (AIGO + BIGO + CIGO + DIGO + EIGO + FIGO)
gen cumIGO=sum(IGOf1)
lab var cumIGO "number of existing IGOs"

***NGOs***
gen NGOf1 = (ANGO + BNGO + CNGO + DNGO + ENGO + FNGO)
gen cumNGO=sum(NGOf1)
lab var cumNGO "number of existing INGOs"
lab var ANGO "number of A-type INGOs founded in a given year"
lab var BNGO "number of B-type INGOs founded in a given year" 
lab var CNGO "number of C-type INGOs founded in a given year"
lab var DNGO "number of D-type INGOs founded in a given year"
lab var ENGO "number of E-type INGOs founded in a given year"
lab var FNGO "number of F-type INGOs founded in a given year"


***Government Activism***
gen govactivism = revexp5/(econ1*pop1)
replace cinc = . if cinc==-9
egen rank_hi = rank(-cinc) , by(year) unique
drop if rank_hi>3
egen num3 = total(govactivism* cinc), by(year) 
egen den3 = total(cinc), by(year) 
gen govactivism_wa3 = num3/den3
drop if rank_hi>2
egen num2 = total(govactivism* cinc), by(year) 
egen den2 = total(cinc), by(year) 
gen govactivism_wa2 = num2/den2
egen govactivism1 = mean(govactivism) if rank_hi==1, by(year)
duplicates drop year,force
lab var govactivism_wa3 "average government activism for the 3 most powerful countries weighted for CINC scores"
lab var govactivism_wa2 "average government activism for the 2 most powerful countries weighted for CINC scores"
lab var govactivism1 "government activism for the most powerful country"
tsset year
tssmooth ma mgovactivism_wa3 = govactivism_wa3, weights( 1/5 <0>)
tssmooth ma mgovactivism_wa2 = govactivism_wa2, weights( 1/5 <0>)
tssmooth ma ma5govactivism1 = govactivism1, weights( 1/5 <0>)
lab var mgovactivism_wa3 "weighted moving average of govactivism_wa3 for 5 years"
lab var mgovactivism_wa2 "weighted moving average of govactivism_wa2 for 5 years"
lab var ma5govactivism1 "weighted moving average of govactivism1 for 5 years"
egen std_mgovactivism_wa3= std(m5govactivism_wa3)
egen std_mgovactivism_wa2= std(m5govactivism_wa2)
egen std_ma5govactivism1= std(m5govactivism_wa3)
lab var std_mgovactivism_wa3 "standardized mgovactivism_wa3"
lab var std_mgovactivism_wa2 "standardized mgovactivism_wa2"
lab var std_ma5govactivism1 "standardized ma5govactivism1"


***Conflict***
gen duration= EndYear- StYear+1
expand duration
bys ccode DispNum3 : gen year=StYear+_n-1
gen var1=1
bysort  ccode year: gen midnum = sum(var1)
bys ccode year: egen midnumsum = max(midnum)
bys ccode year  : keep if _n==1
replace midnumsum = 0 if midnumsum==.
rename midnumsum midnumber
lab var midnumsum "sum of MIDs that each state involved in a given year"
egen mid1= midnumber if rank_hi==1, by(year)
egen mid2= sum(midnumber) if rank_hi<3, by(year)
egen mid3 = sum(midnumber) if rank_hi<4, by(year)
duplicates drop year, force
lab var mid1 "number of MIDs the most powerful country involved in"
lab var mid2 "number of MIDs the two most powerful country involved in"
lab var mid3 "number of MIDs the three most powerful country involved in"
tsset year 
tssmooth ma ma5mid1 = mid1, weights( 1/5 <0>)
tssmooth ma ma5mid2 = mid2, weights( 1/5 <0>)
tssmooth ma ma5mid3 = mid3, weights( 1/5 <0>)
lab var ma5mid1 "weighted moving average of mid1 for 5 years"
lab var ma5mid2 "weighted moving average of mid2 for 5 years"
lab var ma5mid3 "weighted moving average of mid3 for 5 years"


***Interactions***
sum phone1 trade3
gen phone_new= (phone1-1)/9129430
gen trade_new= (trade3-9)/ 1.33e+08
lab var phone_new "rescaled phone1 btw 0-1"
lab var trade_new "rescaled trade3 btw 0-1"
gen interdependence= (phone_new+trade_new)/2
egen interdependence3 = sum(interdependence) if rank_hi<4, by(year)
egen interdependence2 = sum(interdependence) if rank_hi<3, by(year)
egen interdependence1 = sum(interdependence) if rank_hi==1, by(year)
duplicates drop year, force
lab var interdependence3 "sum of interdependence for the most powerful 3 countries"
lab var interdependence2 "sum of interdependence for the most powerful 2 countries"
lab var interdependence1 "sum of interdependence for the most powerful country"
tsset year 
tssmooth ma ma5interdependence3 = interdependence3, weights( 1/5 <0>)
tssmooth ma ma5interdependence2 = interdependence2, weights( 1/5 <0>)
tssmooth ma ma5interdependence1 = interdependence1, weights( 1/5 <0>)
lab var ma5interdependence3 "weighted moving average of interdependence3 for 5 years"
lab var ma5interdependence2 "weighted moving average of interdependence2 for 5 years"
lab var ma5interdependence1 "weighted moving average of interdependence1 for 5 years"
egen std_ma5interdependence3= std(ma5interdependence3)
egen std_ma5interdependence2= std(ma5interdependence2)
egen std_ma5interdependence1= std(ma5interdependence1)


***New States***
gen stateno=1
egen totstate = sum(stateno), by(year)
duplicates drop year,force
gen lag1totstate = totstate[_n-1] if year==year[_n-1]+1
gen totdiff1 = totstate - lag1totstate
gen newstate1 = totdiff/totstate
lab var newstate1 "number of new states last year/number of states"


***Power***
replace cinc = . if cinc==-9
egen cinc1 = max(cinc), by(year)
egen totcinc2 = sum(cinc) if rank_hi<4, by(year)
egen totcinc2 = sum(cinc) if rank_hi<3, by(year)
duplicates drop year, force
lab var cinc1 "cinc score of the most powerful state"
lab var totcinc2 "sum of the cinc scores for the most powerful 2 countries"
lab var totcinc3 "sum of the cinc scores for the most powerful 3 countries"
tsset year 
tssmooth ma ma5cinc1 = cinc1, weights( 1/5 <0>)
tssmooth ma ma5totcinc2 = totcinc2, weights( 1/5 <0>)
tssmooth ma ma5totcinc3 = totcinc3, weights( 1/5 <0>)
lab var ma5cinc1 "weighted moving average of cinc1 for 5 years"
lab var ma5totcinc2 "weighted moving average of totcinc2 for 5 years"
lab var ma5totcinc3 "weighted moving average of totcinc3 for 5 years"
egen std_ma5cinc1= std(ma5cinc1)
egen std_ma5totcinc2= std(ma5totcinc2)
egen std_ma5totcinc3= std(ma5totcinc3)



***Table 1: Government Activism and Establishment of IGOs***
*Model 1.1: Testing the impact of government activism the most powerful state
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5interdependence1 std_ma5cinc1 newstate1 ma5cumIGO ma5cumNGO, rhotype(regress) vce(robust)
*Model 1.2: Testing the impact of government activism the two most powerful states
prais IGOf1 std_mgovactivism_wa2 ma5mid2 std_ma5interdependence2 std_ma5totcinc2 newstate1 ma5cumIGO ma5cumNGO, rhotype(regress) vce(robust)
*Model 1.3: Testing the impact of government activism the three most powerful states
prais IGOf1 std_mgovactivism_wa3 ma5mid3 std_ma5interdependence3 std_ma5totcinc3 newstate1 ma5cumIGO ma5cumNGO , rhotype(regress) vce(robust)



*********TABLE 2******************

*Cleaning data: COW IGO membership
tostring year ccode, replace
year was int now str4
ccode was int now str3

set more off
ds, has(type numeric)
foreach v in `r(varlist)' {
	recode `v' (-1=0)
	recode `v' (2=0)
	recode `v' (3=0)
	recode `v' (-9=.)
	}
egen IOmember = rowtotal(AAAID-Wassen)
lab var IOmember "number of IGO membership for each state per year"


***5 year change in IO membership***DV***--before 1965 
sort ccode year
by ccode: gen lag5IOmember = IOmember[_n-1] if year==year[_n-1]+5
gen IOchange5 =((IOmember-lag5IOmember)/(lag5IOmember))*100
replace IOchange5years= IOchange5 if IOchange5years==.
lab var IOchange5years "% of IO membership change over the past five years"


***Yearly change in IGO membership***DV***--after 1965

sort ccode year
by ccode: gen lag1IOmember = IOmember[_n-1] if year==year[_n-1]+1 
gen IOchange =((IOmember-lag1IOmember)/(lag1IOmember))*100
lab var IOchange "% of annual IO membership change"


***IGOs*** 
egen maxIO = max(IOmember), by(year)
lab var maxIO "maximum # IOs that a state is a member of per year"


***Conflict*** 
gen duration= EndYear- StYear+1
expand duration
bys ccode DispNum3 : gen year=StYear+_n-1
gen var1=1
bysort  ccode year: gen midnum = sum(var1)
bys ccode year: egen midnumsum = max(midnum)
bys ccode year  : keep if _n==1
replace midnumsum = 0 if midnumsum==.
rename midnumsum midnumber
lab var midnumber "sum of MIDs that each state involved in a given year"


***Interdependence***
sum phone trade
gen phone_new= (phone1-1)/7438510
gen trade_new= (trade3-9)/ 9.78e+07
gen interdependence= (phone_new+trade_new)/2
 
lab var interdependence "(phone_new+trade_new)/2"
lab var phone_new "rescaled phone1 btw 0-1"
lab var trade_new "rescaled trade3 btw 0-1"
egen std_interdependence= std(interdependence)



***Table 2: Government Activism and IGO Membership***
*Model 2.1
xtreg IOchange5years std_govactivism midnumber std_interdependence polity2 maxIO, fe
*Model 2.2:
xtreg IOchange std_govactivism midnumber std_interdependence polity2 maxIO, fe



*******APPENDIX***********

***Military expenditure***
replace cinc = . if cinc==-9
egen rank_hi = rank(-cinc) , by(year) unique
egen milexp1 = mean(revexp7) if rank_hi<2, by(year)
duplicates drop year, force
lab var milexp1 "military expenditure/national expenditure for the most powerful state"
tsset year 
tssmooth ma ma5milexp1 = milexp1, weights( 1/5 <0>)
egen std_ma5milexp1= std(ma5milexp1)

***Democracy****
egen rank_hi = rank(-cinc) , by(year) unique
egen democ1 = mean(polity2) if rank_hi<2, by(year)
lab var democ1 "democracy score of the most powerful state"
tsset year
tssmooth ma ma5democ1 = democ1, weights( 1/5 <0>)
lab var ma5democ1 "weighted moving average of democ1 for 5 years"

***Security IGOs***
replace organ1=0 if organ1==1
replace organ1=0 if organ1==2
replace organ1=1 if organ1==3
bysort year: egen organIO = total(organ1)
duplicates drop year, force
lab var organIO "number of IOs in security"
replace organIO=0 if organIO==.
tsset year
tssmooth ma ma5organIO = organIO, weights( 1/5 <0>)
lab var ma5organIO "weighted moving average of organIO for 5 years"


***Table A4: Additional models as robustness checks***
*Model 1.4: controls for military expenditure
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5interdependence1 std_ma5cinc1 newstate1 ma5cumIGO ma5cumNGO std_ma5milexp1 , rhotype(regress) vce(robust)
*MODEL 1.5: only with interactions
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5interdependence1 std_ma5cinc1 newstate1, rhotype(regress)vce(robust)
*MODEL 1.6: only with IGOs
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5cinc1 newstate1 ma5cumIGO, rhotype(regress) vce(robust)
*MODEL 1.7: only with NGOs
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5cinc1 newstate1 ma5cumNGO, rhotype(regress) vce(robust)
*Model 1.8: controls for democracy
prais IGOf1 std_ma5govactivism1 ma5democ1 ma5mid1 std_ma5interdependence1 std_ma5cinc1 newstate1 ma5cumIGO ma5cumNGO, rhotype(regress) vce(robust)
*Model 1.9: controls for GDP
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5interdependence1 ma5econ1 newstate1 ma5cumIGO ma5cumNGO, rhotype(regress) vce(robust)
*Model 1.10: control for security IGOs
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5interdependence1 std_ma5cinc1 newstate1 ma5cumIGO ma5cumNGO ma5organIO , rhotype(regress) vce(robust)
*Model 1.11: DV - INGO emergence
prais NGOf_int std_lag1govactivism1 lag1mid1 std_lag1interdependence1 std_lag1cinc1 lag1cumIGO lag1cumNGO, rhotype(regress) vce(robust)
*Model 1.12: controls for total number of states
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5interdependence1 std_ma5cinc1 lag1totstate ma5cumIGO ma5cumNGO  , rhotype(regress) vce(robust)
*Model 1.13: controls for year
prais IGOf1 std_ma5govactivism1 ma5mid1 std_ma5interdependence1 std_ma5cinc1 newstate1 ma5cumIGO ma5cumNGO year  , rhotype(regress) vce(robust)
*Model 1.14: controls for hegemony(with two most powerful states)
prais IGOf1 std_mgovactivism_wa2 ma5mid2 std_ma5interdependence2 std_ma5cinc1 newstate1 ma5cumIGO ma5cumNGO  , rhotype(regress) vce(robust)
*Model 1.15: controls for hegemony(with three most powerful states)
prais IGOf1 std_mgovactivism_wa3 ma5mid3 std_ma5interdependence3 std_ma5cinc1 newstate1 ma5cumIGO ma5cumNGO  , rhotype(regress) vce(robust)


***Table A5: Robustness checks for Models 1.1, 1.2 and 1.3 using negative binomial regression models***
*Model 1.16: 
nbreg IGOf1 std_ma5govactivism1 ma5mid1 std_ma5interdependence1 std_ma5cinc1 newstate1 ma5cumIGO ma5cumNGO, vce(robust)
*Model 1.17:
nbreg IGOf1 std_mgovactivism_wa2 ma5mid2 std_ma5interdependence2 std_ma5totcinc2 newstate1 ma5cumIGO ma5cumNGO, vce(robust)
*Model 1.18:
nbreg IGOf1 std_mgovactivism_wa3 ma5mid3 std_ma5interdependence3 std_ma5totcinc3 newstate1 ma5cumIGO ma5cumNGO, vce(robust)


